<cfprocessingdirective suppresswhitespace="yes">
<cfif NOT fileexists('#request.basepath#config/styles.cfm') OR isdefined('url.init')>
  <cfsavecontent variable="stylesfiles">
  <!---load theme shared css files--->
  <cfdirectory name="qmaincss" action="list" directory="#request.basepath#themes/#request.site_theme#/css" type="file" filter="*.css">
  <cfloop query="qmaincss">
<cfif NOT qmaincss.name IS 'tinymce.css'>
<cfoutput><link href="#request.absolutepath#themes/#request.site_theme#/css/#qmaincss.name#" type="text/css" rel="stylesheet" />#Chr(13)##Chr(10)#</cfoutput>
</cfif>
  </cfloop>
  <!---load default css files in folder /css--->
  <cfif directoryexists('#request.basepath#css')>
    <cfdirectory name="qdefaultcss" action="list" directory="#request.basepath#/css" type="file" filter="*.css">
    <cfloop query="qdefaultcss">
    <cfif NOT qdefaultcss.name IS 'default.css'>
      <cfif fileexists('#request.basepath#themes/#request.site_theme#/css/#qdefaultcss.name#')>
        <!---do nothing because we already loaded it--->
        <cfelse>
<cfoutput><link href="#request.absolutepath#css/#qdefaultcss.name#" type="text/css" rel="stylesheet" />#Chr(13)##Chr(10)#</cfoutput>
      </cfif>
    </cfif>
    </cfloop>
  </cfif>
  <!---load css for any installed components, will load any defaults if available if custom css is not found--->
  <cfif qcs.recordcount GT 1>
    <cfloop query="qcs">
    <cfif fileexists('#request.basepath#themes/#request.site_theme#/css/#qcs.name#.css')>
<cfoutput><link href="#request.absolutepath#themes/#request.site_theme#/css/#qcs.name#.css" type="text/css" rel="stylesheet" />#Chr(13)##Chr(10)#</cfoutput>
      <cfelse>
      <cfif directoryexists('#request.basepath#components/#qcs.name#/css')>
        <cfdirectory name="qcss" action="list" directory="#request.basepath#components/#qcs.name#/css" type="file" filter="*.css">
        <cfloop query="qcss">
        <cfif right(qcss.name, 4) IS '.css'>
<cfoutput><link href="#request.absolutepath#components/#qcs.name#/css/#qcss.name#" type="text/css" rel="stylesheet" />#Chr(13)##Chr(10)#</cfoutput>
        </cfif>
        </cfloop>
      </cfif>
    </cfif>
    </cfloop>
  </cfif>
  </cfsavecontent>
  <cffile action="write" output="#stylesfiles#" file="#request.basepath#config/styles.cfm">
</cfif>
<cfinclude template="#request.absolutepath#config/styles.cfm">
<!---load layout specific css files: if no css is found for layout this will load nothing--->
<cfif directoryexists('#request.basepath#themes/#request.site_theme#/layouts/#request.layout#/css')>
  <cfdirectory action="list" directory="#request.basepath#themes/#request.site_theme#/layouts/#request.layout#/css" name="qlayoutcss" type="file">
  <cfloop query="qlayoutcss">
  <cfif right(qlayoutcss.name, 4) IS ".css">
<cfoutput><link href="#request.absolutepath#themes/#request.site_theme#/layouts/#request.layout#/css/#qlayoutcss.name#" type="text/css" rel="stylesheet" />#Chr(13)##Chr(10)#</cfoutput>
  </cfif>
  </cfloop>
</cfif>
</cfprocessingdirective>
